{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "# -*- coding: utf-8 -*-\n",
    "\n",
    "from keras.preprocessing import image     #导入numpy、matplotlib、keras、cv2\n",
    "import numpy as np\n",
    "from keras.models import load_model\n",
    "import cv2\n",
    "from matplotlib import pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Model: \"sequential_1\"\n",
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "conv2d_1 (Conv2D)            (None, 28, 28, 16)        160       \n",
      "_________________________________________________________________\n",
      "max_pooling2d_1 (MaxPooling2 (None, 14, 14, 16)        0         \n",
      "_________________________________________________________________\n",
      "conv2d_2 (Conv2D)            (None, 14, 14, 32)        4640      \n",
      "_________________________________________________________________\n",
      "max_pooling2d_2 (MaxPooling2 (None, 7, 7, 32)          0         \n",
      "_________________________________________________________________\n",
      "flatten_1 (Flatten)          (None, 1568)              0         \n",
      "_________________________________________________________________\n",
      "dropout_1 (Dropout)          (None, 1568)              0         \n",
      "_________________________________________________________________\n",
      "dense_1 (Dense)              (None, 128)               200832    \n",
      "_________________________________________________________________\n",
      "dropout_2 (Dropout)          (None, 128)               0         \n",
      "_________________________________________________________________\n",
      "dense_2 (Dense)              (None, 10)                1290      \n",
      "=================================================================\n",
      "Total params: 206,922\n",
      "Trainable params: 206,922\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n",
      "9\n",
      "[<keras.layers.convolutional.Conv2D object at 0x7f529dfb3898>, <keras.layers.pooling.MaxPooling2D object at 0x7f521c53ecc0>, <keras.layers.convolutional.Conv2D object at 0x7f521c53eda0>, <keras.layers.pooling.MaxPooling2D object at 0x7f521c567470>, <keras.layers.core.Flatten object at 0x7f521c567a58>, <keras.layers.core.Dropout object at 0x7f521c567ba8>, <keras.layers.core.Dense object at 0x7f521c567eb8>, <keras.layers.core.Dropout object at 0x7f521bd15dd8>, <keras.layers.core.Dense object at 0x7f521bd15ba8>]\n"
     ]
    }
   ],
   "source": [
    " #加载模型\n",
    "model = load_model('./model1.h5')    \n",
    "# 1、模型概括打印\n",
    "model.summary()\n",
    "#获取网络层数\n",
    "print(len(model.layers))\n",
    "#获取每一层的名称\n",
    "print((model.layers))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=========================================================================\n",
      "该层权重的的维度： 2\n",
      "=========================================================================\n",
      "卷积权重的类型： <class 'numpy.ndarray'>\n",
      "卷积核原本的形状： (3, 3, 1, 16)\n",
      "卷积核转置后的形状： (16, 1, 3, 3)\n",
      "[[[[ 0.0666354  -0.2557925  -0.47615096]\n",
      "   [ 0.42515403  0.02579723 -0.3022666 ]\n",
      "   [ 0.26564986  0.3319464  -0.07938689]]]\n",
      "\n",
      "\n",
      " [[[-0.3806804   0.21002641 -0.05118597]\n",
      "   [-0.13826008  0.19069964  0.2387019 ]\n",
      "   [ 0.27216956  0.01538291  0.03078023]]]\n",
      "\n",
      "\n",
      " [[[-0.3223944   0.20769122  0.14402446]\n",
      "   [-0.26678443  0.1891678   0.17676957]\n",
      "   [-0.14342147  0.13387844  0.07953347]]]\n",
      "\n",
      "\n",
      " [[[ 0.17587216  0.08598987  0.155417  ]\n",
      "   [ 0.1986249   0.13007043 -0.02290112]\n",
      "   [-0.0542796   0.31418377  0.22454724]]]\n",
      "\n",
      "\n",
      " [[[-0.13415551 -0.21434516 -0.3246694 ]\n",
      "   [-0.08730754 -0.0115791   0.190619  ]\n",
      "   [ 0.23075856  0.16311806  0.2560268 ]]]\n",
      "\n",
      "\n",
      " [[[ 0.11932046  0.04667129  0.2790863 ]\n",
      "   [ 0.13258779  0.2526775   0.11732288]\n",
      "   [ 0.17632058 -0.11027954 -0.31829575]]]\n",
      "\n",
      "\n",
      " [[[-0.5152732  -0.14736147  0.3334812 ]\n",
      "   [-0.36237806  0.0508542   0.27297387]\n",
      "   [-0.06689982  0.13282743  0.25136673]]]\n",
      "\n",
      "\n",
      " [[[ 0.08210153  0.06030861 -0.16305606]\n",
      "   [ 0.32265997  0.16920495 -0.1712215 ]\n",
      "   [ 0.33780655  0.25629753 -0.49908912]]]\n",
      "\n",
      "\n",
      " [[[ 0.20682463 -0.0784421  -0.17631584]\n",
      "   [ 0.17338103  0.14627376  0.14988035]\n",
      "   [-0.01627676  0.00883851  0.15920801]]]\n",
      "\n",
      "\n",
      " [[[ 0.12309633  0.24060065  0.2359024 ]\n",
      "   [-0.14466292  0.03044892  0.16666456]\n",
      "   [-0.25851908 -0.2637668   0.17286377]]]\n",
      "\n",
      "\n",
      " [[[-0.25446853 -0.37235594 -0.3435328 ]\n",
      "   [ 0.02685348  0.05920622 -0.06246109]\n",
      "   [ 0.38442308  0.1766148   0.37123725]]]\n",
      "\n",
      "\n",
      " [[[ 0.20196031  0.23331097  0.25533405]\n",
      "   [ 0.0934362   0.10352796  0.22020914]\n",
      "   [-0.45059547 -0.34473827 -0.25253397]]]\n",
      "\n",
      "\n",
      " [[[ 0.3981317   0.36378393  0.22276886]\n",
      "   [-0.02280755  0.07138626 -0.08349169]\n",
      "   [-0.42270485 -0.39087343 -0.22212864]]]\n",
      "\n",
      "\n",
      " [[[ 0.08751288 -0.13691288 -0.32430196]\n",
      "   [ 0.18845637  0.16592672  0.24970715]\n",
      "   [ 0.12511942 -0.07697237  0.1479799 ]]]\n",
      "\n",
      "\n",
      " [[[ 0.29157677 -0.1097867  -0.17149559]\n",
      "   [-0.07405552  0.24285203 -0.1408654 ]\n",
      "   [-0.0452191   0.25230956  0.08730333]]]\n",
      "\n",
      "\n",
      " [[[-0.11871725  0.17595725 -0.39024463]\n",
      "   [ 0.03308137  0.17726249  0.15007223]\n",
      "   [-0.02998754  0.02670641  0.04228859]]]]\n",
      "=========================================================================\n",
      "偏置的类型： <class 'numpy.ndarray'>\n",
      "偏置的形状： (16,)\n",
      "[-0.0037302  -0.08964254 -0.0800216  -0.06283757 -0.01142369 -0.02860047\n",
      " -0.00695542  0.00679138 -0.01455029 -0.03411569 -0.00390801 -0.00562151\n",
      "  0.01899772 -0.12069573 -0.09937542 -0.00498172]\n"
     ]
    }
   ],
   "source": [
    "#获取第零层卷积的权重和偏置\n",
    "layer0 = model.get_layer(index=0) #获取改层\n",
    "weights0 = layer0.get_weights()   #获取该层的参数W和b\n",
    "\n",
    "print('=========================================================================')\n",
    "print(\"该层权重的的维度：\",len(weights0))              #该层权重的的维度：卷积和偏置两项\n",
    "\n",
    "print('=========================================================================')\n",
    "print(\"卷积权重的类型：\",type(weights0[0]))           #打印该层的权重的类型\n",
    "#weights0[0]=weights0[0].astype(np.int16)     #将权重数据类型转为int16\n",
    "\n",
    "\n",
    "print(\"卷积核原本的形状：\",weights0[0].shape)             #打印该层的权重的形状：3行3列16通道\n",
    "#转置3x3x1x16=====>16x1x3x3\n",
    "weights0[0]=weights0[0].transpose(3,2,0,1)\n",
    "print(\"卷积核转置后的形状：\",weights0[0].shape)             #打印该层的权重的形状：3行3列16通道\n",
    "print(weights0[0])             #打印该层的权重\n",
    "#保存卷积权重到二进制bin文件\n",
    "weights0[0].tofile(\"./weight_bin//c1w.bin\")\n",
    "print('=========================================================================')\n",
    "print(\"偏置的类型：\",type(weights0[1]))           #打印该层的权重的类型\n",
    "print(\"偏置的形状：\",weights0[1].shape)             #打印该层的权重的形状：3行3列16通道\n",
    "#转置3x3x1x16=====>16x1x3x3\n",
    "#weights0[0]=weights0[0].transpose(3,2,0,1)\n",
    "print(weights0[1])             #打印该层的权重\n",
    "weights0[1].tofile(\"./weight_bin/c1b.bin\")\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=========================================================================\n",
      "该层权重的的维度： 2\n",
      "=========================================================================\n",
      "卷积权重的类型： <class 'numpy.ndarray'>\n",
      "卷积核原本的形状： (3, 3, 16, 32)\n",
      "卷积核转置后的形状： (32, 16, 3, 3)\n",
      "[[[[ 0.0955558   0.03922452 -0.25097427]\n",
      "   [ 0.16857785 -0.02725656 -0.19132093]\n",
      "   [-0.08175548 -0.10033172 -0.10125921]]\n",
      "\n",
      "  [[-0.04053079 -0.15918678 -0.0583311 ]\n",
      "   [ 0.15658604 -0.15012737  0.11678957]\n",
      "   [-0.05627985  0.08495566 -0.03348925]]\n",
      "\n",
      "  [[-0.02489801 -0.1430895   0.01578913]\n",
      "   [-0.05740668  0.17014503  0.12443769]\n",
      "   [-0.2960375   0.00900051 -0.02006085]]\n",
      "\n",
      "  ...\n",
      "\n",
      "  [[ 0.12181476 -0.06771509  0.04779996]\n",
      "   [ 0.11980715 -0.09162667 -0.06758997]\n",
      "   [ 0.06297724 -0.03517004 -0.11981961]]\n",
      "\n",
      "  [[ 0.0995675  -0.04470449  0.06225052]\n",
      "   [ 0.01354606 -0.06548665  0.00283639]\n",
      "   [-0.11552183  0.07060124  0.14280926]]\n",
      "\n",
      "  [[-0.05744582 -0.09331529 -0.13445722]\n",
      "   [ 0.01491377  0.04618784  0.02726056]\n",
      "   [-0.06708395 -0.02387498  0.07066359]]]\n",
      "\n",
      "\n",
      " [[[ 0.22696668 -0.1819491  -0.16990462]\n",
      "   [-0.15594646 -0.14613439 -0.03920652]\n",
      "   [-0.20097618  0.04570065  0.05844005]]\n",
      "\n",
      "  [[-0.06427912 -0.21440889 -0.12137978]\n",
      "   [-0.08775865 -0.02736151  0.01478237]\n",
      "   [-0.06337792  0.01433417 -0.0914579 ]]\n",
      "\n",
      "  [[-0.11288723 -0.18062535 -0.04444933]\n",
      "   [-0.00262237  0.1112766   0.05882576]\n",
      "   [ 0.06163361  0.06907459 -0.04262268]]\n",
      "\n",
      "  ...\n",
      "\n",
      "  [[ 0.1428195  -0.03340613  0.06406144]\n",
      "   [-0.11480092  0.07513218 -0.04198392]\n",
      "   [-0.04770089  0.0324305  -0.15857896]]\n",
      "\n",
      "  [[ 0.08630023 -0.18081671  0.01564561]\n",
      "   [-0.04858375 -0.08454546 -0.11072223]\n",
      "   [-0.12930466 -0.00612494 -0.11376762]]\n",
      "\n",
      "  [[-0.03673221 -0.10361026 -0.03102699]\n",
      "   [ 0.06277362 -0.03077513 -0.07522719]\n",
      "   [-0.03662864  0.05499087 -0.04932363]]]\n",
      "\n",
      "\n",
      " [[[-0.21872485 -0.04600206 -0.14681925]\n",
      "   [ 0.01665934 -0.02006933  0.03747949]\n",
      "   [-0.17593639 -0.17213732  0.05774368]]\n",
      "\n",
      "  [[ 0.09787745  0.10909182 -0.09165466]\n",
      "   [ 0.16484576  0.03061994 -0.13649926]\n",
      "   [-0.05635973 -0.002563   -0.16347776]]\n",
      "\n",
      "  [[ 0.06752263  0.14683254 -0.01003337]\n",
      "   [ 0.02388988 -0.01064829 -0.18452373]\n",
      "   [ 0.01037424 -0.14303687  0.02130029]]\n",
      "\n",
      "  ...\n",
      "\n",
      "  [[-0.12177341 -0.08957919 -0.16445845]\n",
      "   [ 0.00520639 -0.00602881 -0.06175489]\n",
      "   [-0.05027001 -0.08693469 -0.07113945]]\n",
      "\n",
      "  [[-0.02910148  0.02873401  0.00695461]\n",
      "   [-0.13651685  0.02747775 -0.04680306]\n",
      "   [-0.05423657 -0.09667549 -0.06652523]]\n",
      "\n",
      "  [[ 0.0311785  -0.02156552 -0.07727773]\n",
      "   [ 0.1695022  -0.1279485  -0.2453099 ]\n",
      "   [-0.06154018 -0.15760812 -0.10621265]]]\n",
      "\n",
      "\n",
      " ...\n",
      "\n",
      "\n",
      " [[[ 0.11492304  0.08673267  0.15369599]\n",
      "   [-0.01333063  0.04694709 -0.03870806]\n",
      "   [-0.10907562 -0.06849442 -0.31090716]]\n",
      "\n",
      "  [[-0.10798996  0.01238123 -0.19137774]\n",
      "   [ 0.2176468  -0.08031992 -0.13961822]\n",
      "   [ 0.16935898 -0.24578127  0.0980451 ]]\n",
      "\n",
      "  [[ 0.05910715 -0.0878487   0.05905874]\n",
      "   [ 0.20518392  0.01249476 -0.0188356 ]\n",
      "   [ 0.10596403 -0.00944016  0.10929343]]\n",
      "\n",
      "  ...\n",
      "\n",
      "  [[-0.07838719  0.07891905  0.04706323]\n",
      "   [-0.04638236 -0.11148796 -0.11688848]\n",
      "   [-0.1092254  -0.18160552  0.07852828]]\n",
      "\n",
      "  [[ 0.14624691 -0.0396365  -0.03911755]\n",
      "   [-0.05237772 -0.01441112 -0.09694204]\n",
      "   [-0.01471843 -0.26216203 -0.04304836]]\n",
      "\n",
      "  [[-0.01173772  0.08996396 -0.13015623]\n",
      "   [ 0.18777029 -0.09588093 -0.10576962]\n",
      "   [-0.02950554 -0.20902899  0.12420236]]]\n",
      "\n",
      "\n",
      " [[[ 0.04590278 -0.17860317  0.07137967]\n",
      "   [ 0.11221285  0.02754417  0.1649909 ]\n",
      "   [ 0.13192077  0.03744936  0.21013734]]\n",
      "\n",
      "  [[ 0.01160652 -0.05767563  0.02043308]\n",
      "   [-0.06728684  0.04393332  0.15020432]\n",
      "   [-0.05554047  0.03982605  0.04815052]]\n",
      "\n",
      "  [[-0.02357912  0.1299404   0.02791881]\n",
      "   [-0.00641432  0.01906344  0.17811503]\n",
      "   [ 0.08427557  0.08187588  0.0295646 ]]\n",
      "\n",
      "  ...\n",
      "\n",
      "  [[-0.0918024   0.09235491  0.11111336]\n",
      "   [-0.09318294  0.09984319  0.03431117]\n",
      "   [-0.03362895 -0.11303517  0.08155603]]\n",
      "\n",
      "  [[-0.14578183 -0.02882885  0.02866718]\n",
      "   [-0.11142359  0.03753383  0.14893681]\n",
      "   [-0.00074115 -0.05917517  0.01807706]]\n",
      "\n",
      "  [[-0.17798659 -0.05959046 -0.02164852]\n",
      "   [-0.08222741  0.09652362 -0.00293337]\n",
      "   [ 0.05938501 -0.06835072 -0.020749  ]]]\n",
      "\n",
      "\n",
      " [[[ 0.04179184  0.04210502 -0.04969551]\n",
      "   [ 0.17156662  0.07597131  0.00634526]\n",
      "   [ 0.21742888 -0.06360203 -0.15638229]]\n",
      "\n",
      "  [[-0.2654291  -0.07560079  0.11508243]\n",
      "   [-0.00591572  0.01821787 -0.05184484]\n",
      "   [ 0.08886689 -0.17988265  0.15651368]]\n",
      "\n",
      "  [[-0.3529334   0.18662412  0.03572281]\n",
      "   [ 0.045844    0.04694109  0.04382665]\n",
      "   [ 0.06063257  0.05691431  0.01751063]]\n",
      "\n",
      "  ...\n",
      "\n",
      "  [[-0.16509196 -0.13736776 -0.06241374]\n",
      "   [-0.035858   -0.07968777 -0.0676527 ]\n",
      "   [ 0.02124985 -0.05784285 -0.01186398]]\n",
      "\n",
      "  [[-0.02915951 -0.19493788  0.06419022]\n",
      "   [ 0.09188127  0.01845524 -0.00555864]\n",
      "   [ 0.17320712 -0.0070974  -0.00921163]]\n",
      "\n",
      "  [[-0.05958049 -0.1320519   0.01292856]\n",
      "   [ 0.01105548 -0.03466342 -0.12745084]\n",
      "   [-0.0253722  -0.00596388  0.11007153]]]]\n",
      "=========================================================================\n",
      "偏置的类型： <class 'numpy.ndarray'>\n",
      "偏置原本的形状： (32,)\n",
      "[-0.02272152 -0.00626088 -0.04959327  0.00986751  0.00141975 -0.12516804\n",
      " -0.0922258  -0.0444097  -0.04616328 -0.07257318 -0.04877454 -0.0233861\n",
      " -0.15989418 -0.00274181 -0.00959518  0.01387289 -0.0105739  -0.01821423\n",
      " -0.07709751 -0.0169714   0.0065144  -0.0057805  -0.03332941 -0.07496818\n",
      " -0.00788418 -0.00096073 -0.0157764  -0.00654608 -0.0430148  -0.03144505\n",
      " -0.00370333 -0.04282686]\n"
     ]
    }
   ],
   "source": [
    "#获取第二层卷积的权重和偏置\n",
    "layer2 = model.get_layer(index=2) #获取改层\n",
    "weights2 = layer2.get_weights()   #获取该层的参数W和b\n",
    "print('=========================================================================')\n",
    "print(\"该层权重的的维度：\",len(weights2))              #该层权重的的维度：卷积和偏置两项\n",
    "\n",
    "print('=========================================================================')\n",
    "print(\"卷积权重的类型：\",type(weights2[0]))           #打印该层的权重的类型\n",
    "print(\"卷积核原本的形状：\",weights2[0].shape)             #打印该层的权重的形状：3行3列16通道\n",
    "#转置3x3x16x32=====>32x16x3x3\n",
    "weights2[0]=weights2[0].transpose(3,2,0,1)\n",
    "print(\"卷积核转置后的形状：\",weights2[0].shape)             #打印该层的权重的形状：3行3列16通道\n",
    "print(weights2[0])             #打印该层的权重\n",
    "#保存卷积权重到二进制bin文件\n",
    "weights2[0].tofile(\"./weight_bin//c2w.bin\")\n",
    "\n",
    "print('=========================================================================')\n",
    "print(\"偏置的类型：\",type(weights2[1]))           #打印该层的权重的类型\n",
    "print(\"偏置原本的形状：\",weights2[1].shape)             #打印该层的权重的形状：3行3列16通道\n",
    "print(weights2[1])             #打印该层的权重\n",
    "weights2[1].tofile(\"./weight_bin/c2b.bin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=========================================================================\n",
      "2\n",
      "=========================================================================\n",
      "矩阵权重的类型： <class 'numpy.ndarray'>\n",
      "矩阵权重的总个数： 200704\n",
      "矩阵权重原来的形状： (1568, 128)\n",
      "矩阵权重转置后的形状： (128, 1568)\n",
      "[[-0.01719927 -0.03823454 -0.01932273 ... -0.04921417  0.05377471\n",
      "   0.0252989 ]\n",
      " [-0.04144293 -0.0072552   0.00199412 ...  0.0326843   0.05900571\n",
      "  -0.02609367]\n",
      " [-0.04186489 -0.03022121 -0.03938598 ... -0.05268966  0.05642483\n",
      "   0.0467236 ]\n",
      " ...\n",
      " [ 0.04828049  0.01011903 -0.02746451 ...  0.03128258  0.04817855\n",
      "   0.0346797 ]\n",
      " [-0.02966924 -0.01698747  0.04226634 ...  0.05648492  0.03469853\n",
      "  -0.01776249]\n",
      " [ 0.00390895 -0.03033806  0.04755848 ...  0.04072607 -0.03607173\n",
      "   0.02111315]]\n",
      "=========================================================================\n",
      "偏置的类型： <class 'numpy.ndarray'>\n",
      "偏置形状： (128,)\n",
      "128\n",
      "[-0.07601771 -0.06166385 -0.06526529 -0.01232975 -0.05668816 -0.00570615\n",
      " -0.07438132 -0.06994422 -0.05234959 -0.03183017 -0.09601714 -0.09900951\n",
      " -0.07296367 -0.11196744 -0.11407607 -0.04322184 -0.01594684  0.00234236\n",
      " -0.00509172 -0.0559174  -0.01941404 -0.04869796 -0.06330772 -0.09168445\n",
      " -0.00638195 -0.08302958 -0.03197591  0.00854671 -0.03016883 -0.025873\n",
      " -0.04665476 -0.08542843 -0.09432581 -0.08650593 -0.02547176 -0.0496144\n",
      " -0.05146604 -0.0397908  -0.00294    -0.05809828 -0.10709359 -0.03324924\n",
      " -0.02234198 -0.10016985  0.01373601 -0.05794888 -0.02474223 -0.07925839\n",
      " -0.03635804 -0.0396944  -0.02667447 -0.04169565 -0.06943145 -0.02477394\n",
      " -0.09328254 -0.04698148 -0.074591   -0.04016936 -0.06737196 -0.06272913\n",
      " -0.098612   -0.07966571 -0.03038786 -0.03826346 -0.06206752 -0.08524787\n",
      " -0.01501872 -0.03008646 -0.01603508 -0.09894126  0.00484568 -0.05130474\n",
      " -0.11649687 -0.03363297 -0.05504392 -0.0480268  -0.05032796 -0.05169186\n",
      " -0.07878108 -0.07859845 -0.06190477 -0.02281603 -0.03979008 -0.08060233\n",
      " -0.07443091 -0.11031758 -0.07412477 -0.06336088 -0.05591452 -0.03547946\n",
      " -0.08668626 -0.07401926 -0.06125722 -0.07418317 -0.05678617 -0.03464184\n",
      " -0.06553888 -0.05835684 -0.09319167 -0.08607581  0.00132617 -0.07003727\n",
      " -0.06620283 -0.07956946 -0.05701146  0.00026674 -0.03764935 -0.06709911\n",
      " -0.01725797 -0.06309431 -0.04590928 -0.04002813 -0.06400787 -0.10044698\n",
      " -0.06665077 -0.11387622 -0.08875483 -0.11126214 -0.05121384 -0.01532098\n",
      " -0.07129136 -0.07491609 -0.05565032 -0.04835516 -0.05430748 -0.02287147\n",
      " -0.03523553 -0.03320223]\n"
     ]
    }
   ],
   "source": [
    "#获取第六层全连接的权重和偏置\n",
    "layer6= model.get_layer(index=6) #获取改层\n",
    "weights6 = layer6.get_weights()   #获取该层的参数W和b\n",
    "print('=========================================================================')\n",
    "print(len(weights6))              #该层权重的的维度：权重和偏置两项\n",
    "\n",
    "print('=========================================================================')\n",
    "print(\"矩阵权重的类型：\",type(weights6[0]))            #打印该层的权重的类型\n",
    "print(\"矩阵权重的总个数：\",weights6[0].size)           #权重矩阵的总元素个数\n",
    "print(\"矩阵权重原来的形状：\",weights6[0].shape)          #权重矩阵的形状：行3列16通道\n",
    "\n",
    "weights6[0]=weights6[0].transpose(1,0)\n",
    "print(\"矩阵权重转置后的形状：\",weights6[0].shape)          #权重矩阵的形状：行3列16通道\n",
    "print(weights6[0])             #打印该层的权重\n",
    "#保存卷积权重到二进制bin文件\n",
    "weights6[0].tofile(\"./weight_bin//f6w.bin\")\n",
    "\n",
    "print('=========================================================================')\n",
    "print(\"偏置的类型：\",type(weights6[1]))           #打印该层的偏置的类型\n",
    "print(\"偏置形状：\",weights6[1].shape)             #打印该层的偏置的形状：128x1\n",
    "\n",
    "print(len(weights6[1]))                          #权重矩阵的列数=输入的全连接层输出的元素个数=128\n",
    "print(weights6[1])                               #打印该层的偏置\n",
    "weights6[1].tofile(\"./weight_bin/f6b.bin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=========================================================================\n",
      "2\n",
      "=========================================================================\n",
      "矩阵权重的类型： <class 'numpy.ndarray'>\n",
      "矩阵权重的总个数： 1280\n",
      "矩阵权重的形状： (128, 10)\n",
      "矩阵权重转置后的形状： (10, 128)\n",
      "[[ 6.5374054e-02  8.0505675e-03  1.8855231e-02 ...  1.1503628e-01\n",
      "   1.7478634e-01 -3.4651875e-01]\n",
      " [-2.1446282e-01  8.0545016e-02  1.0711244e-01 ... -2.1804452e-02\n",
      "  -2.1660490e-01 -3.3106476e-01]\n",
      " [ 7.2557196e-02  1.1911153e-01 -2.4351113e-01 ... -2.2517715e-02\n",
      "   1.4211325e-01 -2.5358477e-01]\n",
      " ...\n",
      " [ 4.9617540e-02  1.3024026e-01  9.0554237e-02 ... -1.7421724e-02\n",
      "  -2.4326348e-01  1.2257293e-01]\n",
      " [-7.0328094e-02  6.0543753e-02 -3.3804965e-01 ...  1.5849833e-01\n",
      "  -1.7901991e-01  2.8468052e-02]\n",
      " [-1.5213530e-01 -7.1544036e-02 -7.9816600e-05 ...  1.8914089e-01\n",
      "   1.0847200e-01  6.6742025e-02]]\n",
      "=========================================================================\n",
      "偏置的类型： <class 'numpy.ndarray'>\n",
      "偏置形状： (10,)\n",
      "10\n",
      "[-0.01243159  0.09214074 -0.06272949 -0.02321226 -0.08162592 -0.10588994\n",
      " -0.0844419  -0.11360486  0.13890822  0.1077631 ]\n"
     ]
    }
   ],
   "source": [
    "#获取第八层全连接的权重和偏置\n",
    "layer8= model.get_layer(index=8) #获取改层\n",
    "weights8= layer8.get_weights()   #获取该层的参数W和b\n",
    "print('=========================================================================')\n",
    "print(len(weights8))              #该层权重的的维度：权重和偏置两项\n",
    "\n",
    "print('=========================================================================')\n",
    "print(\"矩阵权重的类型：\",type(weights8[0]))            #打印该层的权重的类型\n",
    "print(\"矩阵权重的总个数：\",weights8[0].size)           #权重矩阵的总元素个数 1280\n",
    "print(\"矩阵权重的形状：\",weights8[0].shape)          #权重矩阵的形状：128x10\n",
    "\n",
    "weights8[0]=weights8[0].transpose(1,0)\n",
    "print(\"矩阵权重转置后的形状：\",weights8[0].shape)          #权重矩阵的形状：行3列16通道\n",
    "\n",
    "print(weights8[0])             #打印该层的权重\n",
    "#保存卷积权重到二进制bin文件\n",
    "weights8[0].tofile(\"./weight_bin//f8w.bin\")\n",
    "\n",
    "print('=========================================================================')\n",
    "print(\"偏置的类型：\",type(weights8[1]))           #打印该层的偏置的类型\n",
    "print(\"偏置形状：\",weights8[1].shape)             #打印该层的偏置的形状：10x1\n",
    "print(len(weights8[1]))                          #权重矩阵的列数=输入的全连接层输出的元素个数=128\n",
    "print(weights8[1])                               #打印该层的偏置\n",
    "weights8[1].tofile(\"./weight_bin/f8b.bin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<keras.layers.core.Dense object at 0x7f521bd15ba8>\n",
      "[array([[ 6.5374054e-02, -2.1446282e-01,  7.2557196e-02, ...,\n",
      "         4.9617540e-02, -7.0328094e-02, -1.5213530e-01],\n",
      "       [ 8.0505675e-03,  8.0545016e-02,  1.1911153e-01, ...,\n",
      "         1.3024026e-01,  6.0543753e-02, -7.1544036e-02],\n",
      "       [ 1.8855231e-02,  1.0711244e-01, -2.4351113e-01, ...,\n",
      "         9.0554237e-02, -3.3804965e-01, -7.9816600e-05],\n",
      "       ...,\n",
      "       [ 1.1503628e-01, -2.1804452e-02, -2.2517715e-02, ...,\n",
      "        -1.7421724e-02,  1.5849833e-01,  1.8914089e-01],\n",
      "       [ 1.7478634e-01, -2.1660490e-01,  1.4211325e-01, ...,\n",
      "        -2.4326348e-01, -1.7901991e-01,  1.0847200e-01],\n",
      "       [-3.4651875e-01, -3.3106476e-01, -2.5358477e-01, ...,\n",
      "         1.2257293e-01,  2.8468052e-02,  6.6742025e-02]], dtype=float32), array([-0.01243159,  0.09214074, -0.06272949, -0.02321226, -0.08162592,\n",
      "       -0.10588994, -0.0844419 , -0.11360486,  0.13890822,  0.1077631 ],\n",
      "      dtype=float32)]\n"
     ]
    }
   ],
   "source": [
    "#获取第八层全连接的权重和偏置\n",
    "print((model.layers[8]))\n",
    "print(model.get_layer(index=8).get_weights())                #打印该层的权重\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[array([[[[ 0.0666354 , -0.3806804 , -0.3223944 ,  0.17587216,\n",
       "           -0.13415551,  0.11932046, -0.5152732 ,  0.08210153,\n",
       "            0.20682463,  0.12309633, -0.25446853,  0.20196031,\n",
       "            0.3981317 ,  0.08751288,  0.29157677, -0.11871725]],\n",
       " \n",
       "         [[-0.2557925 ,  0.21002641,  0.20769122,  0.08598987,\n",
       "           -0.21434516,  0.04667129, -0.14736147,  0.06030861,\n",
       "           -0.0784421 ,  0.24060065, -0.37235594,  0.23331097,\n",
       "            0.36378393, -0.13691288, -0.1097867 ,  0.17595725]],\n",
       " \n",
       "         [[-0.47615096, -0.05118597,  0.14402446,  0.155417  ,\n",
       "           -0.3246694 ,  0.2790863 ,  0.3334812 , -0.16305606,\n",
       "           -0.17631584,  0.2359024 , -0.3435328 ,  0.25533405,\n",
       "            0.22276886, -0.32430196, -0.17149559, -0.39024463]]],\n",
       " \n",
       " \n",
       "        [[[ 0.42515403, -0.13826008, -0.26678443,  0.1986249 ,\n",
       "           -0.08730754,  0.13258779, -0.36237806,  0.32265997,\n",
       "            0.17338103, -0.14466292,  0.02685348,  0.0934362 ,\n",
       "           -0.02280755,  0.18845637, -0.07405552,  0.03308137]],\n",
       " \n",
       "         [[ 0.02579723,  0.19069964,  0.1891678 ,  0.13007043,\n",
       "           -0.0115791 ,  0.2526775 ,  0.0508542 ,  0.16920495,\n",
       "            0.14627376,  0.03044892,  0.05920622,  0.10352796,\n",
       "            0.07138626,  0.16592672,  0.24285203,  0.17726249]],\n",
       " \n",
       "         [[-0.3022666 ,  0.2387019 ,  0.17676957, -0.02290112,\n",
       "            0.190619  ,  0.11732288,  0.27297387, -0.1712215 ,\n",
       "            0.14988035,  0.16666456, -0.06246109,  0.22020914,\n",
       "           -0.08349169,  0.24970715, -0.1408654 ,  0.15007223]]],\n",
       " \n",
       " \n",
       "        [[[ 0.26564986,  0.27216956, -0.14342147, -0.0542796 ,\n",
       "            0.23075856,  0.17632058, -0.06689982,  0.33780655,\n",
       "           -0.01627676, -0.25851908,  0.38442308, -0.45059547,\n",
       "           -0.42270485,  0.12511942, -0.0452191 , -0.02998754]],\n",
       " \n",
       "         [[ 0.3319464 ,  0.01538291,  0.13387844,  0.31418377,\n",
       "            0.16311806, -0.11027954,  0.13282743,  0.25629753,\n",
       "            0.00883851, -0.2637668 ,  0.1766148 , -0.34473827,\n",
       "           -0.39087343, -0.07697237,  0.25230956,  0.02670641]],\n",
       " \n",
       "         [[-0.07938689,  0.03078023,  0.07953347,  0.22454724,\n",
       "            0.2560268 , -0.31829575,  0.25136673, -0.49908912,\n",
       "            0.15920801,  0.17286377,  0.37123725, -0.25253397,\n",
       "           -0.22212864,  0.1479799 ,  0.08730333,  0.04228859]]]],\n",
       "       dtype=float32),\n",
       " array([-0.0037302 , -0.08964254, -0.0800216 , -0.06283757, -0.01142369,\n",
       "        -0.02860047, -0.00695542,  0.00679138, -0.01455029, -0.03411569,\n",
       "        -0.00390801, -0.00562151,  0.01899772, -0.12069573, -0.09937542,\n",
       "        -0.00498172], dtype=float32),\n",
       " array([[[[ 0.0955558 ,  0.22696668, -0.21872485, ...,  0.11492304,\n",
       "            0.04590278,  0.04179184],\n",
       "          [-0.04053079, -0.06427912,  0.09787745, ..., -0.10798996,\n",
       "            0.01160652, -0.2654291 ],\n",
       "          [-0.02489801, -0.11288723,  0.06752263, ...,  0.05910715,\n",
       "           -0.02357912, -0.3529334 ],\n",
       "          ...,\n",
       "          [ 0.12181476,  0.1428195 , -0.12177341, ..., -0.07838719,\n",
       "           -0.0918024 , -0.16509196],\n",
       "          [ 0.0995675 ,  0.08630023, -0.02910148, ...,  0.14624691,\n",
       "           -0.14578183, -0.02915951],\n",
       "          [-0.05744582, -0.03673221,  0.0311785 , ..., -0.01173772,\n",
       "           -0.17798659, -0.05958049]],\n",
       " \n",
       "         [[ 0.03922452, -0.1819491 , -0.04600206, ...,  0.08673267,\n",
       "           -0.17860317,  0.04210502],\n",
       "          [-0.15918678, -0.21440889,  0.10909182, ...,  0.01238123,\n",
       "           -0.05767563, -0.07560079],\n",
       "          [-0.1430895 , -0.18062535,  0.14683254, ..., -0.0878487 ,\n",
       "            0.1299404 ,  0.18662412],\n",
       "          ...,\n",
       "          [-0.06771509, -0.03340613, -0.08957919, ...,  0.07891905,\n",
       "            0.09235491, -0.13736776],\n",
       "          [-0.04470449, -0.18081671,  0.02873401, ..., -0.0396365 ,\n",
       "           -0.02882885, -0.19493788],\n",
       "          [-0.09331529, -0.10361026, -0.02156552, ...,  0.08996396,\n",
       "           -0.05959046, -0.1320519 ]],\n",
       " \n",
       "         [[-0.25097427, -0.16990462, -0.14681925, ...,  0.15369599,\n",
       "            0.07137967, -0.04969551],\n",
       "          [-0.0583311 , -0.12137978, -0.09165466, ..., -0.19137774,\n",
       "            0.02043308,  0.11508243],\n",
       "          [ 0.01578913, -0.04444933, -0.01003337, ...,  0.05905874,\n",
       "            0.02791881,  0.03572281],\n",
       "          ...,\n",
       "          [ 0.04779996,  0.06406144, -0.16445845, ...,  0.04706323,\n",
       "            0.11111336, -0.06241374],\n",
       "          [ 0.06225052,  0.01564561,  0.00695461, ..., -0.03911755,\n",
       "            0.02866718,  0.06419022],\n",
       "          [-0.13445722, -0.03102699, -0.07727773, ..., -0.13015623,\n",
       "           -0.02164852,  0.01292856]]],\n",
       " \n",
       " \n",
       "        [[[ 0.16857785, -0.15594646,  0.01665934, ..., -0.01333063,\n",
       "            0.11221285,  0.17156662],\n",
       "          [ 0.15658604, -0.08775865,  0.16484576, ...,  0.2176468 ,\n",
       "           -0.06728684, -0.00591572],\n",
       "          [-0.05740668, -0.00262237,  0.02388988, ...,  0.20518392,\n",
       "           -0.00641432,  0.045844  ],\n",
       "          ...,\n",
       "          [ 0.11980715, -0.11480092,  0.00520639, ..., -0.04638236,\n",
       "           -0.09318294, -0.035858  ],\n",
       "          [ 0.01354606, -0.04858375, -0.13651685, ..., -0.05237772,\n",
       "           -0.11142359,  0.09188127],\n",
       "          [ 0.01491377,  0.06277362,  0.1695022 , ...,  0.18777029,\n",
       "           -0.08222741,  0.01105548]],\n",
       " \n",
       "         [[-0.02725656, -0.14613439, -0.02006933, ...,  0.04694709,\n",
       "            0.02754417,  0.07597131],\n",
       "          [-0.15012737, -0.02736151,  0.03061994, ..., -0.08031992,\n",
       "            0.04393332,  0.01821787],\n",
       "          [ 0.17014503,  0.1112766 , -0.01064829, ...,  0.01249476,\n",
       "            0.01906344,  0.04694109],\n",
       "          ...,\n",
       "          [-0.09162667,  0.07513218, -0.00602881, ..., -0.11148796,\n",
       "            0.09984319, -0.07968777],\n",
       "          [-0.06548665, -0.08454546,  0.02747775, ..., -0.01441112,\n",
       "            0.03753383,  0.01845524],\n",
       "          [ 0.04618784, -0.03077513, -0.1279485 , ..., -0.09588093,\n",
       "            0.09652362, -0.03466342]],\n",
       " \n",
       "         [[-0.19132093, -0.03920652,  0.03747949, ..., -0.03870806,\n",
       "            0.1649909 ,  0.00634526],\n",
       "          [ 0.11678957,  0.01478237, -0.13649926, ..., -0.13961822,\n",
       "            0.15020432, -0.05184484],\n",
       "          [ 0.12443769,  0.05882576, -0.18452373, ..., -0.0188356 ,\n",
       "            0.17811503,  0.04382665],\n",
       "          ...,\n",
       "          [-0.06758997, -0.04198392, -0.06175489, ..., -0.11688848,\n",
       "            0.03431117, -0.0676527 ],\n",
       "          [ 0.00283639, -0.11072223, -0.04680306, ..., -0.09694204,\n",
       "            0.14893681, -0.00555864],\n",
       "          [ 0.02726056, -0.07522719, -0.2453099 , ..., -0.10576962,\n",
       "           -0.00293337, -0.12745084]]],\n",
       " \n",
       " \n",
       "        [[[-0.08175548, -0.20097618, -0.17593639, ..., -0.10907562,\n",
       "            0.13192077,  0.21742888],\n",
       "          [-0.05627985, -0.06337792, -0.05635973, ...,  0.16935898,\n",
       "           -0.05554047,  0.08886689],\n",
       "          [-0.2960375 ,  0.06163361,  0.01037424, ...,  0.10596403,\n",
       "            0.08427557,  0.06063257],\n",
       "          ...,\n",
       "          [ 0.06297724, -0.04770089, -0.05027001, ..., -0.1092254 ,\n",
       "           -0.03362895,  0.02124985],\n",
       "          [-0.11552183, -0.12930466, -0.05423657, ..., -0.01471843,\n",
       "           -0.00074115,  0.17320712],\n",
       "          [-0.06708395, -0.03662864, -0.06154018, ..., -0.02950554,\n",
       "            0.05938501, -0.0253722 ]],\n",
       " \n",
       "         [[-0.10033172,  0.04570065, -0.17213732, ..., -0.06849442,\n",
       "            0.03744936, -0.06360203],\n",
       "          [ 0.08495566,  0.01433417, -0.002563  , ..., -0.24578127,\n",
       "            0.03982605, -0.17988265],\n",
       "          [ 0.00900051,  0.06907459, -0.14303687, ..., -0.00944016,\n",
       "            0.08187588,  0.05691431],\n",
       "          ...,\n",
       "          [-0.03517004,  0.0324305 , -0.08693469, ..., -0.18160552,\n",
       "           -0.11303517, -0.05784285],\n",
       "          [ 0.07060124, -0.00612494, -0.09667549, ..., -0.26216203,\n",
       "           -0.05917517, -0.0070974 ],\n",
       "          [-0.02387498,  0.05499087, -0.15760812, ..., -0.20902899,\n",
       "           -0.06835072, -0.00596388]],\n",
       " \n",
       "         [[-0.10125921,  0.05844005,  0.05774368, ..., -0.31090716,\n",
       "            0.21013734, -0.15638229],\n",
       "          [-0.03348925, -0.0914579 , -0.16347776, ...,  0.0980451 ,\n",
       "            0.04815052,  0.15651368],\n",
       "          [-0.02006085, -0.04262268,  0.02130029, ...,  0.10929343,\n",
       "            0.0295646 ,  0.01751063],\n",
       "          ...,\n",
       "          [-0.11981961, -0.15857896, -0.07113945, ...,  0.07852828,\n",
       "            0.08155603, -0.01186398],\n",
       "          [ 0.14280926, -0.11376762, -0.06652523, ..., -0.04304836,\n",
       "            0.01807706, -0.00921163],\n",
       "          [ 0.07066359, -0.04932363, -0.10621265, ...,  0.12420236,\n",
       "           -0.020749  ,  0.11007153]]]], dtype=float32),\n",
       " array([-0.02272152, -0.00626088, -0.04959327,  0.00986751,  0.00141975,\n",
       "        -0.12516804, -0.0922258 , -0.0444097 , -0.04616328, -0.07257318,\n",
       "        -0.04877454, -0.0233861 , -0.15989418, -0.00274181, -0.00959518,\n",
       "         0.01387289, -0.0105739 , -0.01821423, -0.07709751, -0.0169714 ,\n",
       "         0.0065144 , -0.0057805 , -0.03332941, -0.07496818, -0.00788418,\n",
       "        -0.00096073, -0.0157764 , -0.00654608, -0.0430148 , -0.03144505,\n",
       "        -0.00370333, -0.04282686], dtype=float32),\n",
       " array([[-0.01719927, -0.04144293, -0.04186489, ...,  0.04828049,\n",
       "         -0.02966924,  0.00390895],\n",
       "        [-0.03823454, -0.0072552 , -0.03022121, ...,  0.01011903,\n",
       "         -0.01698747, -0.03033806],\n",
       "        [-0.01932273,  0.00199412, -0.03938598, ..., -0.02746451,\n",
       "          0.04226634,  0.04755848],\n",
       "        ...,\n",
       "        [-0.04921417,  0.0326843 , -0.05268966, ...,  0.03128258,\n",
       "          0.05648492,  0.04072607],\n",
       "        [ 0.05377471,  0.05900571,  0.05642483, ...,  0.04817855,\n",
       "          0.03469853, -0.03607173],\n",
       "        [ 0.0252989 , -0.02609367,  0.0467236 , ...,  0.0346797 ,\n",
       "         -0.01776249,  0.02111315]], dtype=float32),\n",
       " array([-0.07601771, -0.06166385, -0.06526529, -0.01232975, -0.05668816,\n",
       "        -0.00570615, -0.07438132, -0.06994422, -0.05234959, -0.03183017,\n",
       "        -0.09601714, -0.09900951, -0.07296367, -0.11196744, -0.11407607,\n",
       "        -0.04322184, -0.01594684,  0.00234236, -0.00509172, -0.0559174 ,\n",
       "        -0.01941404, -0.04869796, -0.06330772, -0.09168445, -0.00638195,\n",
       "        -0.08302958, -0.03197591,  0.00854671, -0.03016883, -0.025873  ,\n",
       "        -0.04665476, -0.08542843, -0.09432581, -0.08650593, -0.02547176,\n",
       "        -0.0496144 , -0.05146604, -0.0397908 , -0.00294   , -0.05809828,\n",
       "        -0.10709359, -0.03324924, -0.02234198, -0.10016985,  0.01373601,\n",
       "        -0.05794888, -0.02474223, -0.07925839, -0.03635804, -0.0396944 ,\n",
       "        -0.02667447, -0.04169565, -0.06943145, -0.02477394, -0.09328254,\n",
       "        -0.04698148, -0.074591  , -0.04016936, -0.06737196, -0.06272913,\n",
       "        -0.098612  , -0.07966571, -0.03038786, -0.03826346, -0.06206752,\n",
       "        -0.08524787, -0.01501872, -0.03008646, -0.01603508, -0.09894126,\n",
       "         0.00484568, -0.05130474, -0.11649687, -0.03363297, -0.05504392,\n",
       "        -0.0480268 , -0.05032796, -0.05169186, -0.07878108, -0.07859845,\n",
       "        -0.06190477, -0.02281603, -0.03979008, -0.08060233, -0.07443091,\n",
       "        -0.11031758, -0.07412477, -0.06336088, -0.05591452, -0.03547946,\n",
       "        -0.08668626, -0.07401926, -0.06125722, -0.07418317, -0.05678617,\n",
       "        -0.03464184, -0.06553888, -0.05835684, -0.09319167, -0.08607581,\n",
       "         0.00132617, -0.07003727, -0.06620283, -0.07956946, -0.05701146,\n",
       "         0.00026674, -0.03764935, -0.06709911, -0.01725797, -0.06309431,\n",
       "        -0.04590928, -0.04002813, -0.06400787, -0.10044698, -0.06665077,\n",
       "        -0.11387622, -0.08875483, -0.11126214, -0.05121384, -0.01532098,\n",
       "        -0.07129136, -0.07491609, -0.05565032, -0.04835516, -0.05430748,\n",
       "        -0.02287147, -0.03523553, -0.03320223], dtype=float32),\n",
       " array([[ 6.5374054e-02, -2.1446282e-01,  7.2557196e-02, ...,\n",
       "          4.9617540e-02, -7.0328094e-02, -1.5213530e-01],\n",
       "        [ 8.0505675e-03,  8.0545016e-02,  1.1911153e-01, ...,\n",
       "          1.3024026e-01,  6.0543753e-02, -7.1544036e-02],\n",
       "        [ 1.8855231e-02,  1.0711244e-01, -2.4351113e-01, ...,\n",
       "          9.0554237e-02, -3.3804965e-01, -7.9816600e-05],\n",
       "        ...,\n",
       "        [ 1.1503628e-01, -2.1804452e-02, -2.2517715e-02, ...,\n",
       "         -1.7421724e-02,  1.5849833e-01,  1.8914089e-01],\n",
       "        [ 1.7478634e-01, -2.1660490e-01,  1.4211325e-01, ...,\n",
       "         -2.4326348e-01, -1.7901991e-01,  1.0847200e-01],\n",
       "        [-3.4651875e-01, -3.3106476e-01, -2.5358477e-01, ...,\n",
       "          1.2257293e-01,  2.8468052e-02,  6.6742025e-02]], dtype=float32),\n",
       " array([-0.01243159,  0.09214074, -0.06272949, -0.02321226, -0.08162592,\n",
       "        -0.10588994, -0.0844419 , -0.11360486,  0.13890822,  0.1077631 ],\n",
       "       dtype=float32)]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.get_weights() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
